package com.sportradar.assessment.work.beans;

import java.util.Date;

import lombok.Getter;
import lombok.Setter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
 * Bean keeping the state of current statistics values
 * reset() is called before every statistic's unit of time
 *
 */
public class StatisticsBean {

	private static Logger logger=LoggerFactory.getLogger(StatisticsBean.class);
			
	@Getter private long computationSpeed;
	@Getter private int iterationNumber;
	@Getter @Setter private Date lastUpdate;
	
	public StatisticsBean(){
		resetStatistics();
	}

	public void incrementComputationSpeed(long addedSpeedInNanoSeconds){
		this.computationSpeed=this.computationSpeed+addedSpeedInNanoSeconds;
	}
	
	public void incrementIterationNumber(){
		iterationNumber++;
	}
	
	public void resetStatistics(){
		logger.info("reset statistics");
		this.computationSpeed=0L;
		this.iterationNumber=0;
		
	}
}
